package ch.trackedbean.server.data.converter;

import ch.trackedbean.copier.*;

/**
 * Converter for String to Int conversion.
 * 
 * @author M. Hautle
 */
public class StringToInt implements IPropertyConverter<String, Integer> {
    /**
     * {@inheritDoc}
     */
    @Override
    public String convertDst2Src(Integer dst, String srcVal, Class<? extends String> src, IMappingContext ctx) {
        return dst != null ? dst.toString() : null;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Integer convertSrc2Dst(String src, Integer dstVal, Class<? extends Integer> dst, IMappingContext ctx) {
        return src != null ? Integer.valueOf(src) : new Integer(0);
    }
}
